package com.zt.bigdata.vertx.config

import com.zt.bigdata.vertx.config.Config.{HttpConfig, RedisConfig, VertxConfig, WSConfig}
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Configuration

import scala.beans.BeanProperty

/**
  *
  */
@Configuration
@ConfigurationProperties(prefix = "myvertx")
class Config {
  @BeanProperty
  var vertx = new VertxConfig()
  @BeanProperty
  var ws = new WSConfig()
  @BeanProperty
  var http = new HttpConfig()
  @BeanProperty
  var redis = new RedisConfig()
}

object Config {

  class HttpConfig {
    @BeanProperty
    var port = 7777
    @BeanProperty
    var allowOrigin: String = "*"
  }

  class VertxConfig {
    @BeanProperty
    var eventLoopPoolSize = 4
    @BeanProperty
    var workerPoolSize = 100
    @BeanProperty
    var internalBlockingPoolSize = 100
    @BeanProperty
    var maxWorkerExecuteTime = 20000000000L
    @BeanProperty
    var warningExceptionTime = 10000000000L

  }

  class WSConfig {
    @BeanProperty
    var port = 8087
  }

  class RedisConfig {
    @BeanProperty
    var host: String = _
    @BeanProperty
    var port: Int = 0
    @BeanProperty
    var auth: String = _
    @BeanProperty
    var defaultDB: Int = 0
  }

}
